'''
该文件为地面目标实体
'''
import math
import numpy as np
import pandas as pd

class SAM:
    def __init__(self,SAM_name,攻击间隔=20,攻击半径=20):
        self.name=SAM_name
        self.cd=攻击间隔
        self.att_radius=攻击半径
        self.Position=[]
        self.speed=0
        self.cool=0
        # self.v_missile=0.5
        self.live=1

    def Attack_CD_result(self):
        if self.cool == 0:
            return True
        else:
            return False

    def Attack(self, dt):
        # print("$$$$$$$$$$$$$$$$$$$$查看冷却时间$$$$$$$$$$$$$$$$$$$$$$$$$$")
        # 仍有问题
        # print(self.cool)
        if self.cool == 0:
            return True
        else:
            self.__CD(dt)
            return False

    def cd_reset(self):
        self.cool = self.cd

    def __CD(self, dt):
        self.cool-=dt
        if self.cool<0:
            self.cool=0

    # 计算双方单位的距离
    def distance_xyz(self, A, B):
        x = B[0] - A[0]
        y = B[1] - A[1]
        z = B[2] - A[2]
        dis = math.sqrt(x ** 2 + y ** 2 + z ** 2)
        return dis

